<?php

Class TripleDES {
    public static function encrypt($s_input, $s_key, $b_padded = true, $b_hexed = true, $b_cbc_mode = false, $s_iv=false) {
        if($b_cbc_mode){
            $s_mode = MCRYPT_MODE_CBC;
        } else{
            $s_mode = MCRYPT_MODE_ECB;    
        }
        
        if($b_padded){
            $s_input=TripleDES::padBuffer($s_input);
        }
        
        if($s_iv === false){
            $s_iv=mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_3DES,$s_mode),MCRYPT_RAND);
        }
    
        $s_encrypted = mcrypt_encrypt (MCRYPT_3DES, $s_key, $s_input, $s_mode, $s_iv); 
        
        if ($b_hexed) $s_encrypted = bin2hex($s_encrypted); 
        
        return $s_encrypted; 
    }
    
    private static function padBuffer($s_input) {
        $s_padVal = 8 - (strlen($s_input) % 8);
        return str_pad($s_input, strlen($s_input) + $s_padVal, chr($s_padVal));
    }
    
    public static function hex2bin($s_hexdata) {
        return pack('H'.strlen($s_hexdata), $s_hexdata);
    }
}

$key = 'Z3kR8a#$^#$G^@$l5Q!5@Vj1';
$baseURL = "https://site.recognia.com/fxphc/serve.shtml?tkn=";

$token = "page=featured_forex";
$token .= "&usi=testUser";
$token .= "&aci=" . gmdate("YmdHis");
$token .= "&lang=cs";

print $baseURL . urlencode(base64_encode(TripleDES::encrypt($token, $key, false, false)));

?>